<?php
	include_once("../include/init.php");
	extract($_POST);
	//处理订单数据
	$addr = trim($addr);
	$user = trim($user);
	$tel = trim($tel);
	$order_sn = time().rand(1,1000);
	$user_id = $_SESSION['uid'];
	$user = trim($user);
	$time = time();
	// $cart = json_encode($_SESSION['goods']);
	  $cart = serialize($_SESSION['goods']);
	 //判断收货地址不为空
	if(empty($addr)){
		msg("收货地址不能为空");
	}
	if(empty($user)){
		msg('收货人不能为空');
	}
	if(empty($tel)){
		msg('手机号码不能为空');
	}

	//数据库处理
	
	$sql = "INSERT INTO tr_order(order_sn,user_id,consignee,mobile,address,order_amount,order_goods,add_time) values('$order_sn','$user_id','$user','$tel','$addr','$sum','$cart',$time)";
	$res = mysql_query($sql);
	if(mysql_affected_rows()>0){
		msg("提交订单成功","order_list.php");
	}else{
		msg("提交失败","order.php");
	}




	
?>